package me.stephenj.experiment2.mapper;

import me.stephenj.experiment2.model.Company;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

/**
 * @Title CompanyMapper.java
 * @Description CompanyMapper类
 * @author 张润天
 * @Time 2020/4/21 17:31
 * @version v0.01
 */

@Component
public interface CompanyMapper {

    /**
     * @Title Method
     * @Description 查找公司编号最大值
     */
    @Select("SELECT MAX(`ID`) FROM Company")
    int max();

    /**
     * @Title Method
     * @Description 根据公司编号查找公司信息
     */
    @Select("SELECT * FROM Company WHERE ID=#{ID}")
    Company getAll(int ID);

    /**
     * @Title Method
     * @Description 添加公司信息
     */
    @Insert("INSERT INTO Company (ID, Name, Address) VALUE (#{ID}, #{Name}, #{Address})")
    int insert(Company company);

    /**
     * @Title Method
     * @Description 修改公司信息
     */
    @Update("UPDATE Company SET Name=#{Name}, Address=#{Address} WHERE ID=#{ID}")
    int update(Company company);

    /**
     * @Title Method
     * @Description 删除公司
     */
    @Delete("DELETE FROM Company WHERE ID=#{ID}")
    int delete(int ID);
}
